<?php if (!defined('THINK_PATH')) exit();?><html>
<head>
    <meta charset="utf-8">
    <link href="/Public/css/Admin/Bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="/Public/css/Admin/my.css" rel="stylesheet" />
    <link href="/Public/css/Admin/Validform/Validform.css" rel="stylesheet" />
    <link href="/Public/css/Home/your.css" rel="stylesheet" type="text/css">

    <script language="JavaScript" src="/Public/js/Admin/jquery.1.11.3.min.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/my.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Bootstrap/bootstrap.min.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Bootstrap/bootstrap-treeview.js"></script>
    <script language="JavaScript" src="/Public/js/Admin/Validform/Validform_v5.3.2_min.js"></script>
    <script language="JavaScript" src="/Public/js/Home/your.js"></script>

    <script type="text/javascript">
        $(function(){
             $(".registerform").Validform();
        })
    </script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container" style="width: 100%;padding:0;">
        <div class="navbar-collapse collapse" style="width: 100%;padding:0;">
            <ul class="nav navbar-nav" style="width: 100%">
                <li <?php if(session('column_select') == ''): ?>class="active "<?php endif; ?>><a  style="padding-left:30px;padding-right:30px" href="<?php echo U('modules/columnSelect');?>">首页</a></li>
                <?php if(session('admin_modules') != ''): $_result=session('admin_modules')['modules'];if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><li
                            <?php if(session('column_select') != ''): if($val['id'] == session('column_select') ): ?>class="active"<?php endif; endif; ?>
                        >
                        <a style="padding-left:30px;padding-right:30px" href="<?php echo U('modules/columnSelect?id='.$val['id']);?>"  ><?php echo ($val["name"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; endif; ?>
                <li class="active" style="float:right"><a style="background-color:rgba(92, 173, 136, 0.92)" href="<?php echo U('index/quit');?>">退 出</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-2">
            <ul id="main-nav" class="nav nav-tabs nav-stacked" style="">
                <li class="active">
                    <a style="cursor:pointer"><i class="glyphicon glyphicon-th-large"></i>&nbsp;列表</a>
                </li>
                <?php if(session('modules_select') != ''): $_result=session('modules_select');if(is_array($_result)): $i = 0; $__LIST__ = $_result;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><li>
                            <a href="#systemSetting<?php echo ($val["id"]); ?>" class="nav-header collapsed" data-toggle="collapse">
                                <i class="glyphicon glyphicon-cog"></i><?php echo ($val["name"]); ?><span class="pull-right glyphicon glyphicon-chevron-down"></span>
                            </a>
                            <ul id="systemSetting<?php echo ($val["id"]); ?>" class="nav nav-list secondmenu collapse "  >
                                <?php if(is_array($val["list"])): $i = 0; $__LIST__ = $val["list"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val2): $mod = ($i % 2 );++$i;?><li><a id="color-eee<?php echo ($val["id"]); ?>-<?php echo ($val2["id"]); ?>" href="<?php echo U('Modules/select?id='.$val2['id']);?>"><i class="glyphicon glyphicon-user "></i><?php echo ($val2["name"]); ?></a></li>
                                    <?php if($val2['url'] != ''): if($val2['id'] == session('select') ): ?><script>
                                                $(document).ready(function(){
                                                    $("#systemSetting<?php echo ($val["id"]); ?>").addClass("in");
                                                    $("#color-eee<?php echo ($val["id"]); ?>-<?php echo ($val2["id"]); ?>").addClass("color-eee");
                                                });
                                            </script><?php endif; endif; endforeach; endif; else: echo "" ;endif; ?>
                            </ul>
                        </li><?php endforeach; endif; else: echo "" ;endif; endif; ?>
            </ul>
        </div>
        <div class="col-md-10" style="padding-left:0px;">
            <div class="panel panel-primary margin10" style="float:left;width:100%;min-height:650px;border-color:#3C4049;">
                <div class="panel-heading" style="background-color: #3C4049;">&nbsp;</div>
                <div class="panel-body">




<link href="/Public/css/Admin/Ztree/metro.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="/Public/js/Admin/Ztree/jquery.ztree.all-3.5.min.js"></script>
<script>
    var zTree;
    var demoIframe;
    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        var addStr ="";
        if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
        addStr += "<span class='button add'    title='添加' id='addBtn_" + treeNode.tId + "'></span>";
        addStr += "<span class='button edit'   title='编辑' id='editBtn_" + treeNode.tId + "'></span>";
        addStr += "<span class='button remove' title='删除' id='removeBtn_" + treeNode.tId
        + "' title='add node' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        sObj.click(function(){
            window.location.href='<?php echo U('/Admin/Article/index');?>'+'?id='+treeNode.id;
        });
        var btn = $("#addBtn_"+treeNode.tId);
        if (btn) btn.bind("click", function(){
            window.location.href='<?php echo U('/Admin/Column/addShow');?>'+'?id='+treeNode.id;
            //alert(treeNode.id);
            /*
             var zTree = $.fn.zTree.getZTreeObj("treeDemo");
             zTree.addNodes(treeNode, {id:(1000 + newCount), pId:treeNode.id, name:"new node" + (newCount++)});
             return false;
             */
        });
        var edit_btn = $("#editBtn_"+treeNode.tId);
        if (edit_btn) edit_btn.bind("click", function(){
            window.location.href='<?php echo U('/Admin/Column/editorShow');?>'+'?id='+treeNode.id;
        });

        var remove_btn = $("#removeBtn_"+treeNode.tId);
        if (remove_btn) remove_btn.bind("click", function(){
            if(confirm("是否删除该栏目")){
                window.location.href='<?php echo U('/Admin/Column/del');?>'+'?id='+treeNode.id;
            }

        });
    };
    $(function(){
        var setting = {
            check: {
                enable: true
            },
            view: {
                addHoverDom: addHoverDom,
                removeHoverDom: removeHoverDom,
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable:true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function(treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        demoIframe.attr("src",treeNode.file + ".html");
                        return true;
                    }
                }
            }
        };
        $.ajax({
            type: 'POST',
            url:"<?php echo U('Column/index');?>",
            data: {subsection:'123'},
            success: function(data){
                zNodes = new Array();
                var obj = eval('(' + data + ')') ;
                $.each(obj,function(key,val){
                    zNodes[key] = {id:val.column_id, pId:val.column_parent, name:val.name};
                    if(val.column_open == '1') {
                        zNodes[key].open = true;
                    }else{
                        zNodes[key].open = false;
                    }
                });
                var t = $("#tree");
                t = $.fn.zTree.init(t, setting, zNodes);
                demoIframe = $("#testIframe");
                demoIframe.bind("load", loadReady);
                var zTree = $.fn.zTree.getZTreeObj("tree");
                zTree.selectNode(zTree.getNodeByParam("id", 101));
            }
        });
        $.ajax({
            type: 'POST',
            url:"<?php echo U('Column/info');?>",
            success: function(data){
                var html="";
                var obj = eval('(' + data + ')') ;
                $.each(obj,function(key,val){
                    html+=val.name+' > ';
                });
                $("#right_title").html(html);
            }
        });

    });

    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_"+treeNode.tId).unbind().remove();
        $("#removeBtn_"+treeNode.tId).unbind().remove();
        $("#editBtn_"+treeNode.tId).unbind().remove();
    };
    function loadReady() {
        var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
                htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
                maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
                h = demoIframe.height() >= maxH ? minH:maxH ;
        if (h < 530) h = 530;
        demoIframe.height(h);
    }


</script>

<div class="panel panel-primary margin10" style="float:left;width:20%;">
    <div class="panel-heading">
        <h3 class="panel-title wrfont16">Tree</h3>
    </div>
    <div class="panel-body">
        <ul id="tree" class="ztree"></ul>
    </div>
</div>
<div class="panel panel-primary margin10" style="float:left;width:75%">
    <div class="panel-heading">
        <h3 class="panel-title wrfont16" id="right_title"></h3>
    </div>
    <div class="panel-body">

<div style="float:left;width:100%">
    <form action="<?php echo U('Column/editor');?>" method="post" enctype="multipart/form-data" class="registerform">
        <div class="form-group width50">
            <label for="exampleInputEmail1">栏目名称：</label><font color="red">*</font>
            <input type="text" class="form-control"  placeholder="栏目名称" name="name" datatype="*1-15"  nullmsg="栏目名称不可为空！" errormsg="请输入1~15个汉字" value="<?php echo ($list["name"]); ?>">
        </div>
        <?php if($rank == 1): ?><div class="form-group width50">
                <label for="exampleInputEmail1">Code：</label><font color="red">*(作为栏目唯一值)</font>
                <input type="text" class="form-control"  placeholder="Code" name="code" datatype="*"  nullmsg="Code不可为空！" value="<?php echo ($list["code"]); ?>">
            </div><?php endif; ?>

        <div class="form-group width50">
            <label for="exampleInputEmail1">是否导航处显示：</label>
            <select class="form-control width50 " name="show">
                <option value="0" <?php if($list['show'] == 0): ?>selected<?php endif; ?>>不显示</option>
                <option value="1" <?php if($list['show'] == 1): ?>selected<?php endif; ?>>显示</option>
            </select>
        </div>

        <!-- 栏目背景图案 -->
        <div class="form-group width50">
            <label for="exampleInputEmail1">栏目背景图案：</label>
            <link href="/Public/css/Admin/Bootstrap/onceUpload/fileinput.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="/Public/js/Admin/Bootstrap/onceUpload/fileinput.js"></script>
<script language="JavaScript" src="/Public/js/Admin/Bootstrap/onceUpload/fileinput_locale_fr.js"></script>
<script language="JavaScript" src="/Public/js/Admin/Bootstrap/onceUpload/fileinput_locale_es.js"></script>
<input name="title_img" type="file" multiple data-show-upload="false" data-show-caption="true" >
<script type="text/javascript">

    if('<?php echo ($list["title_img"]); ?>' != '') {
        $("input[name=title_img]").fileinput({
            initialPreview: [
                "<img src='<?php echo ($list["title_img"]); ?>' class='file-preview-image' alt='The Moon' title='The Moon'>"
            ]
        });
    } else{
        $("input[name=title_img]").fileinput({});
    }

</script>

        </div>

        <!-- 文章内容 -->
        <div class="form-group">
            <label for="exampleInputEmail1">栏目内容：</label>
            
            <script>
    var serverUrlConfig =  "<?php echo U('Upload/config');?>";
</script>
<script language="JavaScript" src="/Public/js/vendor/ueditor/ueditor.config.js"></script>
<script language="JavaScript" src="/Public/js/vendor/ueditor/ueditor.all.min.js"></script>
<script language="JavaScript" src="/Public/js/vendor/ueditor/lang/zh-cn/zh-cn.js"></script>
<style type="text/css">
	div{width:100%; }
</style>
<div>
	<script id="editor" type="text/plain" style="width:100%;height:500px;"><?php echo (html_entity_decode($list["content"])); ?></script>
</div>
<script type="text/javascript">
	var ue = UE.getEditor('editor');
</script>

        </div>



        <!--
        <div class="form-group">
            <label for="exampleInputPassword1">栏目简介：</label>
            <textarea class="form-control" rows="3" name="content"></textarea>
        </div>
        <div class="form-group">
            <label for="exampleInputPassword1">排序</label>
            <select class="form-control width20" name="sort">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                <option>4</option>
                <option>5</option>
            </select>
        </div>
        -->
        <button type="submit" class="btn btn-primary">保存</button>
        <input type="hidden" name="column_id" value="<?php echo ($column_id); ?>" >
    </form>
</div>

</div>
</div>
</div>
</body>
</html>